package com.tengju.user.infrastructure.repository.convert;

import com.tengju.user.domain.model.archive.sign.SignLog;
import com.tengju.user.domain.shared.DateUtil;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.SignLogDO;
import java.time.LocalDateTime;
import java.util.Date;

public class SignLogConvert {

    public static SignLogDO convert(SignLog signLog) {
        if (signLog == null){
            return null;
        }
        SignLogDO signLogDO = new SignLogDO();
        signLogDO.setIdCode(signLog.getIdCode().getValue());
        signLogDO.setOperateType(signLog.getOperateType());
        signLogDO.setBeforeIdentity(signLog.getBeforeIdentity().getVal());
        signLogDO.setLastIdentity(signLog.getLastIdentity().getVal());
        signLogDO.setCreatedBy(signLog.getCreatedBy());
        Date date = DateUtil.localDateTimeToDate(LocalDateTime.now());
        signLogDO.setCreatedTime(date);
        signLogDO.setUpdatedTime(date);
        return signLogDO;
    }
}
